#include "myCond.hpp"
#include <unistd.h>

using namespace MyCondModule;
using namespace MutexModule;

Cond cond;
Mutex mutex;

void *func(void *args)
{
    const char *name = reinterpret_cast<const char *>(args);
    while (true)
    {
        MutexGuard mutexguard(mutex);

        cond.wait(mutex);

        printf("我是线程%s\n", name);
    }
}

int main()
{
    pthread_t tidA, tidB;
    pthread_create(&tidA, nullptr, func, (void *)"A");
    pthread_create(&tidB, nullptr, func, (void *)"B");
    sleep(1);
    printf("主线程来咯:\n");
    while (true)
    {
        cond.signal();
        sleep(1);
    }

    pthread_join(tidA, nullptr);
    pthread_join(tidB, nullptr);
    return 0;
}